package uuid

import "github.com/lithammer/shortuuid"

const (
	shortIDLen = 12
	longIDlen  = 16
)

const (
	//  prefix of userid
	UID         = "UID-"
	EID         = "EID-"
	workorderID = "WOID-"
	workorderAnnouncementID = "WOAID-"

)

// newShortID generate short uuid and add type prefix
func newShortID(prefix string) string {
	return newId(prefix, shortIDLen)
}
func newId(prefix string, len int) string {
	uuid := shortuuid.New()
	return prefix + uuid[:len]
}

// newLongID generate long uuid and add type prefix
func newLongID(prefix string) string {
	return newId(prefix, longIDlen)
}
func New16LengthsCode() string {
	return newLongID("")
}

func NewUserID() string {
	return newShortID(UID)
}

func NewShortID(prefix string) string {
	return newShortID(prefix)
}

func NewEnterpriseID() string {
	return newShortID(EID)
}

func NewJobId() string {
	return newShortID("JID-")
}

func NewWorkorder() string {
	return newShortID(workorderID)
}

func NewWorkorderAnnouncement() string {
	return newShortID(workorderAnnouncementID)
}
